import Vue from 'vue'
import App from './App'
import store from './store'

// 全局日志输出
Vue.prototype.$log = function() {
	// 开发环境输出
	if (process.env.NODE_ENV === 'development') {
		console.log(...arguments);
	}
}

// 全局跳转封装
Vue.prototype.$navigateTo = function(to = '', data = {}) {
	if (!to) return 0;
	if (data != null || data != undefined || typeof data != 'object') {
		let keys = Object.keys(data);
		if (keys.length > 0) {
			let args = "";
			for (let key in data) {
				// 对链接进行编码
				if(/^(http|https):/.test(data[key])){
					args += `&${key}=${encodeURIComponent(data[key])}`;
				}else{
					args += `&${key}=${data[key]}`;
				}
			}
			to += `?${args.slice(1)}`;
		}
	}
	uni.navigateTo({
		url: to
	})
}

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	store,
	...App
})
app.$mount()
